﻿Imports DataDynamics.ActiveReports
Imports DataDynamics.ActiveReports.Document
Imports Tom0014
Imports Tom0014TableAdapters

Public Class ReporteLista
    Inherits DataDynamics.ActiveReports.ActiveReport3

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call
    End Sub
    ' Sobrecarga del metodo new
    Public Sub New(ByVal iReporte As Integer)
        MyBase.New()
        Reporte(iReporte)
    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
        End If
        MyBase.Dispose(disposing)
    End Sub
    Public WithEvents Encabezado As DataDynamics.ActiveReports.PageHeader
    Public WithEvents Detalles As DataDynamics.ActiveReports.Detail
    Private WithEvents lblTitulo As DataDynamics.ActiveReports.Label
    Private WithEvents line1 As DataDynamics.ActiveReports.Line
    Public WithEvents PieDePagina As DataDynamics.ActiveReports.PageFooter
    Dim xPos As New Single
    Const xDis As Single = 0.03!                ' Valor de la distancia entre objeto

#Region " ActiveReports Designer generated code "
    'NOTE: The following procedure is required by the ActiveReports Designer
    'It can be modified using the ActiveReports Designer.
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        'Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Resources.ReporteLista))
        Me.Encabezado = New DataDynamics.ActiveReports.PageHeader
        Me.lblTitulo = New DataDynamics.ActiveReports.Label
        Me.line1 = New DataDynamics.ActiveReports.Line
        Me.Detalles = New DataDynamics.ActiveReports.Detail
        Me.PieDePagina = New DataDynamics.ActiveReports.PageFooter
        CType(Me.lblTitulo, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me, System.ComponentModel.ISupportInitialize).BeginInit()
        '
        'Encabezado
        '
        Me.Encabezado.Controls.Add(Me.lblTitulo)
        Me.Encabezado.Controls.Add(Me.line1)
        Me.Encabezado.Height = 0.72!
        Me.Encabezado.Name = "Encabezado"
        '
        'lblTitulo
        '
        Me.lblTitulo.Border.BottomColor = System.Drawing.Color.Black
        Me.lblTitulo.Border.BottomStyle = DataDynamics.ActiveReports.BorderLineStyle.None
        Me.lblTitulo.Border.LeftColor = System.Drawing.Color.Black
        Me.lblTitulo.Border.LeftStyle = DataDynamics.ActiveReports.BorderLineStyle.None
        Me.lblTitulo.Border.RightColor = System.Drawing.Color.Black
        Me.lblTitulo.Border.RightStyle = DataDynamics.ActiveReports.BorderLineStyle.None
        Me.lblTitulo.Border.TopColor = System.Drawing.Color.Black
        Me.lblTitulo.Border.TopStyle = DataDynamics.ActiveReports.BorderLineStyle.None
        Me.lblTitulo.ClassName = "Heading1"
        Me.lblTitulo.Height = 0.25!
        Me.lblTitulo.HyperLink = Nothing
        Me.lblTitulo.Left = 4.2!
        Me.lblTitulo.Name = "lblTitulo"
        Me.lblTitulo.Style = ""
        Me.lblTitulo.Text = "Santa Fe del Campo"
        Me.lblTitulo.Top = 0.0!
        Me.lblTitulo.Width = 2.2!
        '
        'line1
        '
        Me.line1.Border.BottomColor = System.Drawing.Color.Black
        Me.line1.Border.BottomStyle = DataDynamics.ActiveReports.BorderLineStyle.None
        Me.line1.Border.LeftColor = System.Drawing.Color.Black
        Me.line1.Border.LeftStyle = DataDynamics.ActiveReports.BorderLineStyle.None
        Me.line1.Border.RightColor = System.Drawing.Color.Black
        Me.line1.Border.RightStyle = DataDynamics.ActiveReports.BorderLineStyle.None
        Me.line1.Border.TopColor = System.Drawing.Color.Black
        Me.line1.Border.TopStyle = DataDynamics.ActiveReports.BorderLineStyle.None
        Me.line1.Height = 0.0!
        Me.line1.Left = 0.0!
        Me.line1.LineWeight = 1.0!
        Me.line1.Name = "line1"
        Me.line1.Top = 0.5!
        Me.line1.Width = 10.6!
        Me.line1.X1 = 0.0!
        Me.line1.X2 = 10.6!
        Me.line1.Y1 = 0.5!
        Me.line1.Y2 = 0.5!
        
        '
        'Detalles
        '
        Me.Detalles.ColumnSpacing = 0.0!
        Me.Detalles.Height = 0.2!
        Me.Detalles.Name = "Detalles"
        '
        'PieDePagina
        '
        Me.PieDePagina.Height = 0.2!
        Me.PieDePagina.Name = "PieDePagina"
        '
        'ReporteLista
        '
        Me.MasterReport = False
        Me.PageSettings.DefaultPaperSize = False
        Me.PageSettings.Gutter = 0.1!
        Me.PageSettings.Margins.Bottom = 0.1!
        Me.PageSettings.Margins.Left = 0.1!
        Me.PageSettings.Margins.Right = 0.1!
        Me.PageSettings.Margins.Top = 0.1!
        Me.PageSettings.Orientation = DataDynamics.ActiveReports.Document.PageOrientation.Landscape
        Me.PageSettings.PaperHeight = 11.0!
        Me.PageSettings.PaperWidth = 8.5!
        Me.PrintWidth = 10.6!
        Me.Sections.Add(Me.Encabezado)
        Me.Sections.Add(Me.Detalles)
        Me.Sections.Add(Me.PieDePagina)
        Me.StyleSheet.Add(New DDCssLib.StyleSheetRule("font-family: Arial; font-style: normal; text-decoration: none; font-weight: norma" & _
                    "l; color: Black; ddo-char-set: 204; font-size: 8pt; ", "Normal"))
        Me.StyleSheet.Add(New DDCssLib.StyleSheetRule("font-weight: bold; ddo-char-set: 204; font-size: 14pt; ", "Heading1", "Normal"))
        Me.StyleSheet.Add(New DDCssLib.StyleSheetRule("font-family: Times New Roman; font-size: 14pt; font-weight: bold; font-style: ita" & _
                    "lic; ", "Heading2", "Normal"))
        Me.StyleSheet.Add(New DDCssLib.StyleSheetRule("font-size: 13pt; font-weight: bold; ", "Heading3", "Normal"))
        CType(Me.lblTitulo, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me, System.ComponentModel.ISupportInitialize).EndInit()

    End Sub
#End Region
#Region "Reporte en lista"
    ''' <summary>
    ''' Genera un reporte en formato lista, al instanciar se debera generar:
    ''' </summary>
    ''' <param name="iReporte">indica el numero de reporte a generar</param>
    ''' <remarks></remarks>
    <System.Diagnostics.DebuggerStepThrough()> _
    Public Sub Reporte(ByVal iReporte As Integer)

        ' Distancia entre palabras
        Dim campos As New ReportesDataTable         ' Obten los datos de campo
        Dim _campos As New ReportesTableAdapter
        Dim sWhere As String                            ' sWhere contiene la condicion
        Dim miUtil As New utileria
        Dim sSQL As String = "SELECT * FROM animal "    ' sSQL contiene la cadena sql

        Dim sdsAnima As New DataDynamics.ActiveReports.DataSources.SqlDBDataSource
        Me.Encabezado = New DataDynamics.ActiveReports.PageHeader
        Me.Detalles = New DataDynamics.ActiveReports.Detail
        Me.PieDePagina = New DataDynamics.ActiveReports.PageFooter
        Me.lblTitulo = New DataDynamics.ActiveReports.Label
        Me.line1 = New DataDynamics.ActiveReports.Line
        CType(Me.lblTitulo, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me, System.ComponentModel.ISupportInitialize).BeginInit()


        ' TODO: Terminar con instanacias
        campos = _campos.GetReporteById(iReporte)

        xPos = 0.0!         'Lo posicionamos al inicio del reporte
        If campos.Count = 1 Then ' Si existe registro en la tabla reporte
            sdsAnima.ConnectionString = ConfigurationManager.ConnectionStrings("GanaderiaConnectionString").ConnectionString
            Dim iFiltro As Integer = campos(0).idFiltro()
            sWhere = miUtil.sWhereFiltro(iFiltro)
            sSQL += sWhere & " ORDER BY NUMERO, LETRA, ANO, SEXO"
            sdsAnima.SQL = sSQL  ' TODO: Evitar SQL estatico
            Me.DataSource = sdsAnima ' Agrega el origen de datos al reporte

            ' *****************************************
            '           Rotulos del reporte
            ' *****************************************
            Dim lblReporte As New DataDynamics.ActiveReports.Label
            CType(lblReporte, System.ComponentModel.ISupportInitialize).BeginInit()
            lblReporte = LabelAsigna(lblReporte, "lblReporte", "REPORTE:", 0.65!, 0.2!)
            lblReporte.Top = 0.1!
            Me.Encabezado.Controls.Add(lblReporte)
            CType(lblReporte, System.ComponentModel.ISupportInitialize).EndInit()
            Dim txtReporte As New DataDynamics.ActiveReports.TextBox
            CType(txtReporte, System.ComponentModel.ISupportInitialize).BeginInit()
            txtReporte.Border.BottomColor = System.Drawing.Color.Black
            txtReporte.Border.BottomStyle = DataDynamics.ActiveReports.BorderLineStyle.None
            txtReporte.Border.LeftColor = System.Drawing.Color.Black
            txtReporte.Border.LeftStyle = DataDynamics.ActiveReports.BorderLineStyle.None
            txtReporte.Border.RightColor = System.Drawing.Color.Black
            txtReporte.Border.RightStyle = DataDynamics.ActiveReports.BorderLineStyle.None
            txtReporte.Border.TopColor = System.Drawing.Color.Black
            txtReporte.Border.TopStyle = DataDynamics.ActiveReports.BorderLineStyle.None
            txtReporte.Height = 0.2!
            txtReporte.Left = 0.82!
            txtReporte.Name = "txtReporte"
            txtReporte.Style = "text-align: left; "
            txtReporte.Text = campos(0).NombreReporte
            txtReporte.Top = 0.1!
            txtReporte.Width = 3.0!
            CType(txtReporte, System.ComponentModel.ISupportInitialize).EndInit()
            Me.Encabezado.Controls.Add(txtReporte)

            Dim filtro As New filtroDataTable
            Dim _filtro As New filtroTableAdapter
            filtro = _filtro.GetFiltroById(campos(0).idFiltro)

            Dim lblFiltro As New DataDynamics.ActiveReports.Label
            CType(lblFiltro, System.ComponentModel.ISupportInitialize).BeginInit()
            lblFiltro = LabelAsigna(lblFiltro, "lblFiltro", "FILTRO:", 0.5!, 7.0!)
            lblFiltro.Top = 0.1!
            Me.Encabezado.Controls.Add(lblFiltro)
            CType(lblFiltro, System.ComponentModel.ISupportInitialize).EndInit()
            Dim txtFiltro As New DataDynamics.ActiveReports.TextBox
            CType(txtFiltro, System.ComponentModel.ISupportInitialize).BeginInit()
            txtFiltro.Border.BottomColor = System.Drawing.Color.Black
            txtFiltro.Border.BottomStyle = DataDynamics.ActiveReports.BorderLineStyle.None
            txtFiltro.Border.LeftColor = System.Drawing.Color.Black
            txtFiltro.Border.LeftStyle = DataDynamics.ActiveReports.BorderLineStyle.None
            txtFiltro.Border.RightColor = System.Drawing.Color.Black
            txtFiltro.Border.RightStyle = DataDynamics.ActiveReports.BorderLineStyle.None
            txtFiltro.Border.TopColor = System.Drawing.Color.Black
            txtFiltro.Border.TopStyle = DataDynamics.ActiveReports.BorderLineStyle.None
            txtFiltro.Height = 0.2!
            txtFiltro.Left = 7.52!
            txtFiltro.Name = "txtFiltro"
            txtFiltro.Style = "text-align: left; "
            txtFiltro.Text = filtro(0).nombreFiltro
            txtFiltro.Top = 0.1!
            txtFiltro.Width = 3.0!
            CType(txtFiltro, System.ComponentModel.ISupportInitialize).EndInit()
            Me.Encabezado.Controls.Add(txtFiltro)

            Dim lblImpreso As New DataDynamics.ActiveReports.Label
            CType(lblImpreso, System.ComponentModel.ISupportInitialize).BeginInit()
            lblImpreso = LabelAsigna(lblImpreso, "lblImpreso", "Impreso:", 0.65!, 0.2!)
            lblImpreso.Top = 0.0!
            Me.PieDePagina.Controls.Add(lblImpreso) ' Agrega el objeto
            CType(lblImpreso, System.ComponentModel.ISupportInitialize).EndInit()
            Dim txtImpreso As New DataDynamics.ActiveReports.TextBox
            CType(txtImpreso, System.ComponentModel.ISupportInitialize).BeginInit()
            txtImpreso.Border.BottomColor = System.Drawing.Color.Black
            txtImpreso.Border.BottomStyle = DataDynamics.ActiveReports.BorderLineStyle.None
            txtImpreso.Border.LeftColor = System.Drawing.Color.Black
            txtImpreso.Border.LeftStyle = DataDynamics.ActiveReports.BorderLineStyle.None
            txtImpreso.Border.RightColor = System.Drawing.Color.Black
            txtImpreso.Border.RightStyle = DataDynamics.ActiveReports.BorderLineStyle.None
            txtImpreso.Border.TopColor = System.Drawing.Color.Black
            txtImpreso.Border.TopStyle = DataDynamics.ActiveReports.BorderLineStyle.None
            txtImpreso.Height = 0.2!
            txtImpreso.Left = 0.82!
            txtImpreso.Name = "txtImpreso"
            txtImpreso.OutputFormat = "dd/MM/yyyy"
            txtImpreso.Style = "text-align: left; "
            txtImpreso.Text = Date.Now()
            txtImpreso.Top = 0.0!
            txtImpreso.Width = 3.0!
            CType(txtImpreso, System.ComponentModel.ISupportInitialize).EndInit()
            Me.PieDePagina.Controls.Add(txtImpreso)

            Dim lblHojas As New DataDynamics.ActiveReports.ReportInfo
            CType(lblHojas, System.ComponentModel.ISupportInitialize).BeginInit()
            lblHojas.Alignment = TextAlignment.Left
            lblHojas.Height = 0.2!
            lblHojas.Left = 5.0!
            lblHojas.FormatString = "{PageNumber} / {PageCount}"
            lblHojas.Name = "lblHojas"
            lblHojas.Width = 0.5!
            Me.PieDePagina.Controls.Add(lblHojas)
            CType(lblHojas, System.ComponentModel.ISupportInitialize).EndInit()


            Dim lblImpresoPor As New DataDynamics.ActiveReports.Label
            CType(lblImpresoPor, System.ComponentModel.ISupportInitialize).BeginInit()
            lblImpresoPor = LabelAsigna(lblImpresoPor, "lblImpresoPor", "Usuario:", 0.5!, 8.5!)
            lblImpresoPor.Top = 0.0!
            Me.PieDePagina.Controls.Add(lblImpresoPor)
            CType(lblImpresoPor, System.ComponentModel.ISupportInitialize).EndInit()
            Dim txtImpresoPor As New DataDynamics.ActiveReports.TextBox
            CType(txtImpresoPor, System.ComponentModel.ISupportInitialize).BeginInit()
            txtImpresoPor.Border.BottomColor = System.Drawing.Color.Black
            txtImpresoPor.Border.BottomStyle = DataDynamics.ActiveReports.BorderLineStyle.None
            txtImpresoPor.Border.LeftColor = System.Drawing.Color.Black
            txtImpresoPor.Border.LeftStyle = DataDynamics.ActiveReports.BorderLineStyle.None
            txtImpresoPor.Border.RightColor = System.Drawing.Color.Black
            txtImpresoPor.Border.RightStyle = DataDynamics.ActiveReports.BorderLineStyle.None
            txtImpresoPor.Border.TopColor = System.Drawing.Color.Black
            txtImpresoPor.Border.TopStyle = DataDynamics.ActiveReports.BorderLineStyle.None
            txtImpresoPor.Height = 0.2!
            txtImpresoPor.Left = 9.02!
            txtImpresoPor.Name = "txtImpresoPor"
            txtImpresoPor.Text = Membership.GetUser.UserName()
            txtImpresoPor.Top = 0.0!
            txtImpresoPor.Width = 2.0!
            CType(txtImpresoPor, System.ComponentModel.ISupportInitialize).EndInit()
            Me.PieDePagina.Controls.Add(txtImpresoPor)


            ' ***************************************************
            '               DATOS A PRESENTAR
            ' ***************************************************

            ' ********** HIERRO ***********************************
            If campos(0).Hierro Then Agrega("Hierro", "HIE", "hierro", 0.3!)
            ' ************** SEXO ***************************************
            If campos(0).Sexo Then Agrega("Sexo", "SX", "sexo", 0.2!)
            ' ************* IDENTIFICACION ******************************
            If campos(0).Identificacion Then Agrega("Identidad", "Animal", "= numero + letra + ano", 0.6!)
            ' ********************** NOMBRE ******************************
            If campos(0).Nombre Then Agrega("Nombre", "NOMBRE", "nombre", 1.05!)
            ' ********************** CS ***************************************
            If campos(0).Cs Then Agrega("CS", "% CS", "porcien_cs", 0.4!)
            ' ******************* EDAD **************************************
            If campos(0).Edad Then Agrega("Edad", "Edad", "edad", 0.3!)
            ' ****************** Fecha Nacimiento **********************************
            If campos(0).FechaNac Then Agrega("FechaNac", "F. NAC", "fechanac", 0.6!, "dd/MM/yyyy")


            ' ************** Tienta AC ***************************************
            If campos(0).TientaAC Then Agrega("Tienta_AC", "TC", "tienta_ac", 0.25!)
            ' ************** Tienta AP ***************************************
            If campos(0).TientaAP Then Agrega("TientaAP", "TP", "tienta_ap", 0.25!)
            ' ************** Lidia AC ***************************************
            If campos(0).LidiaAC Then Agrega("LidiaAC", "LC", "lidia_ac", 0.25!)
            ' ************** Lidia AP ***************************************
            If campos(0).LidiaAP Then Agrega("LidiaAP", "LP", "lidia_ap", 0.25!)


            ' TODO: Falta por anexar los demas abuelos
            ' ****************** PADRE *************************************
            If campos(0).Gen_Padre Then Agrega("Padre", "PADRE", "= no_padre + ltra_padre + ano_padre", 0.6!)
            ' ****************** MADRE *************************************
            If campos(0).Gen_Madre Then Agrega("Madre", "MADRE", "= no_madre + ltra_madre + ano_madre", 0.6!)
            ' *********************** ABUELO MATERNO ***********************
            If campos(0).Gen_AbueloMat Then Agrega("AbueloMat", "ABUELO", "abuelo_mat", 0.6!)


            ' *************** UBICACION ************************************
            If campos(0).Gral_Ubicacion Then Agrega("GralUbicacion", "UBI", "ubicacion", 0.3!)
            ' *************** PROPIEDAD **************************
            If campos(0).Gral_Propiedad Then Agrega("Propiedad", "PRO", "propiedad", 0.3!)
            ' *************** ENCASTE *********************
            If campos(0).Gral_Encaste Then Agrega("Encaste", "ENC", "encaste", 0.3!)
            ' *************** REG. ANCTL *********************
            If campos(0).Gral_RegANCTL Then Agrega("RegANCTL", "ANCTL", "reg_ANCTL", 0.8!)

            ' ********** Estatus ***********************************
            If campos(0).Est_Estatus Then Agrega("Estatus", "ST", "estatus", 0.3!)
            ' ********** Causa muerte ***********************************
            If campos(0).Est_CausaMuerte Then Agrega("Muerto", "CM", "muerto", 0.3!)
            ' ********** Fecha ubicacion ***********************************
            If campos(0).Est_FUbucacion Then Agrega("FechaUbica", "F. UBICA", "FechaUbica", 0.6!)
            ' ********** Fecha muerte ***********************************
            If campos(0).Est_FMuerte Then Agrega("FechaMuerte", "F. Muer", "fechamuerte", 0.6!, "dd/MM/yyyy")
            ' ********** Fecha Herradero ***********************************
            If campos(0).Est_FHerradero Then Agrega("Fecha_Herradero", "F.HERR", "fecha_herradero", 0.6!, "dd/MM/yyyy")
            ' ********** Fecha Baja ***********************************
            If campos(0).Est_Baja Then Agrega("FechaBaja", "F. BAJA", "fechabaja", 0.6!, "dd/MM/yyyy")

            ' ****************** ADN ***********************************************
            If campos(0).Her_ADN Then Agrega("ADN", "ADN", "adn", 0.3!)
            ' ********************* FENOTIPO **************************************
            If campos(0).Her_Fenotipo Then Agrega("Fenotipo", "FEN", "fenotipo", 0.3!)
            ' ********************* COMPORTAMIENTO *******************************
            If campos(0).Her_Comportamiento Then Agrega("Comportamiento", "COMP", "comportamiento", 0.3!)


            ' **************** PELAJE 1 ***************************
            If campos(0).Mor_Pelaje1 Then Agrega("Pelaje1", "PEL1", "pelaje1", 0.35!)
            ' **************** PELAJE 2 ***************************
            If campos(0).Mor_Pelaje2 Then Agrega("Pelaje2", "PEL2", "pelaje2", 0.35!)
            ' **************** PELAJE 3 ***************************
            If campos(0).Mor_Pelaje3 Then Agrega("Pelaje3", "PEL3", "pelaje3", 0.35!)
            ' **************** PELAJE 4 ***************************
            If campos(0).Mor_Pelaje4 Then Agrega("Pelaje4", "PEL4", "pelaje4", 0.35!)

            ' *************** PITONES LONGITUD **********************
            If campos(0).MorPit_Longitud Then Agrega("PitonLog", "P LG", "piton_long", 0.3!)
            ' *************** PITONES SIMETRIA *********************
            If campos(0).MorPit_Simetria Then Agrega("PitonSime", "P SM", "piton_sime", 0.3!)
            ' *************** PITONES PUNTAS*********************
            If campos(0).MorPit_Puntas Then Agrega("PitonPuntas", "P PT", "piton_punta", 0.3!)
            ' *************** PITONES FORMAS *********************
            If campos(0).MorPit_Formas Then Agrega("PitonFormas", "P FR", "piton_forma", 0.3!)

            ' *************** HECHURAS TAMAÑO ******************************* 
            If campos(0).MorHec_Tamano Then Agrega("HecTamano", "H TM", "hec_tamaño", 0.3!)
            ' *************** HECHURAS LONGITUD ******************************* 
            If campos(0).MorHec_Longitud Then Agrega("HecLongitud", "H LG", "hec_longitud", 0.3!)
            ' *************** HECHURAS ALTURA ******************************* 
            If campos(0).MorHec_Altura Then Agrega("HecAltura", "H AL", "hec_altura", 0.3!)
            ' *************** HECHURAS AGUJAS ******************************* 
            If campos(0).MorHec_Agujas Then Agrega("HecAgujas", "H AG", "hec_agujas", 0.3!)
            ' *************** HECHURAS ANCHURAS ******************************* 
            If campos(0).MorHec_Agujas Then Agrega("HecAnchura", "H AN", "hec_anchura", 0.3!)
            ' *************** HECHURAS LOMO ******************************* 
            If campos(0).MorHec_Lomo Then Agrega("HecLomo", "H LM", "hec_lomo", 0.3!)
            ' *************** HECHURAS CUELLO ******************************* 
            If campos(0).MorHec_Cuello Then Agrega("HecCuello", "H CE", "hec_cuello", 0.3!)
            ' *************** HECHURAS CZA TAMAÑO ******************************* 
            If campos(0).MorHec_CzaTam Then Agrega("HecCzaTam", "H CT", "hec_cabeza_tam", 0.3!)
            ' *************** HECHURAS CZA TIPO ******************************* 
            If campos(0).MorHec_CzaTipo Then Agrega("HecCzaTipo", "H CT", "hec_cabeza_tip", 0.3!)
            ' *************** HECHURAS CONJUNTO ******************************* 
            If campos(0).MorHec_Conjunto Then Agrega("HecConjunto", "H CN", "hec_conjunto", 0.3!)
            ' *************** HECHURAS TRAPIO ******************************* 
            If campos(0).MorHec_Trapio Then Agrega("HecTrapio", "H T", "hec_trapio", 0.3!)
            ' *************** HECHURAS MORRILLO ******************************* 
            If campos(0).MorHec_Morrillo Then Agrega("HecMorrillo", "H MR", "hec_morrillo", 0.3!)

        Else

            ' ****  Enviamos un error al procesar el reporte *****
            Dim lblError As New DataDynamics.ActiveReports.Label
            CType(lblError, System.ComponentModel.ISupportInitialize).BeginInit()
            lblError = LabelAsigna(lblError, "lblError", "ERROR:  No se pudo procesar el reporte", 4.0!, 3.0!)
            lblError.Height = 0.25!
            lblError.ClassName = "Heading2"
            lblError.ForeColor = Drawing.Color.DarkRed
            Me.Encabezado.Controls.Add(lblError)
            CType(lblError, System.ComponentModel.ISupportInitialize).EndInit()
        End If


        '
        'Encabezado
        '
        Me.Encabezado.Controls.Add(Me.lblTitulo)
        Me.Encabezado.Controls.Add(Me.line1)
        Me.Encabezado.Height = 0.72!
        Me.Encabezado.Name = "Encabezado"
        '
        'line1
        '
        Me.line1.Border.BottomColor = System.Drawing.Color.Black
        Me.line1.Border.BottomStyle = DataDynamics.ActiveReports.BorderLineStyle.None
        Me.line1.Border.LeftColor = System.Drawing.Color.Black
        Me.line1.Border.LeftStyle = DataDynamics.ActiveReports.BorderLineStyle.None
        Me.line1.Border.RightColor = System.Drawing.Color.Black
        Me.line1.Border.RightStyle = DataDynamics.ActiveReports.BorderLineStyle.None
        Me.line1.Border.TopColor = System.Drawing.Color.Black
        Me.line1.Border.TopStyle = DataDynamics.ActiveReports.BorderLineStyle.None
        Me.line1.Height = 0.0!
        Me.line1.Left = 0.0!
        Me.line1.LineWeight = 1.0!
        Me.line1.Name = "line1"
        Me.line1.Top = 0.5!
        Me.line1.Width = 10.6!
        Me.line1.X1 = 0.0!
        Me.line1.X2 = 10.6!
        Me.line1.Y1 = 0.7!
        Me.line1.Y2 = 0.7!
        '
        'lblTitulo
        '
        Me.lblTitulo.Border.BottomColor = System.Drawing.Color.Black
        Me.lblTitulo.Border.BottomStyle = DataDynamics.ActiveReports.BorderLineStyle.None
        Me.lblTitulo.Border.LeftColor = System.Drawing.Color.Black
        Me.lblTitulo.Border.LeftStyle = DataDynamics.ActiveReports.BorderLineStyle.None
        Me.lblTitulo.Border.RightColor = System.Drawing.Color.Black
        Me.lblTitulo.Border.RightStyle = DataDynamics.ActiveReports.BorderLineStyle.None
        Me.lblTitulo.Border.TopColor = System.Drawing.Color.Black
        Me.lblTitulo.Border.TopStyle = DataDynamics.ActiveReports.BorderLineStyle.None
        Me.lblTitulo.ClassName = "Heading1"
        Me.lblTitulo.Height = 0.25!
        Me.lblTitulo.HyperLink = Nothing
        Me.lblTitulo.Left = 4.2!
        Me.lblTitulo.Name = "lblTitulo"
        Me.lblTitulo.Style = ""
        Me.lblTitulo.Text = "Santa Fe del Campo"
        Me.lblTitulo.Top = 0.0!
        Me.lblTitulo.Width = 2.2!

        
        '
        'Detalles
        '
        Me.Detalles.ColumnSpacing = 0.0!
        Me.Detalles.Height = 0.2!
        Me.Detalles.Name = "Detalles"
        '
        'PieDePagina
        '
        Me.PieDePagina.Height = 0.2!
        Me.PieDePagina.Name = "PieDePagina"
        '
        'ReporteLista
        '

        Me.MasterReport = False
        Me.PageSettings.DefaultPaperSize = False
        Me.PageSettings.Gutter = 0.1!
        Me.PageSettings.Margins.Bottom = 0.1!
        Me.PageSettings.Margins.Left = 0.1!
        Me.PageSettings.Margins.Right = 0.1!
        Me.PageSettings.Margins.Top = 0.1!
        Me.PageSettings.Orientation = DataDynamics.ActiveReports.Document.PageOrientation.Landscape
        Me.PageSettings.PaperHeight = 11.0!
        Me.PageSettings.PaperWidth = 8.5!
        Me.PrintWidth = 10.6!
        Me.Sections.Add(Me.Encabezado)
        Me.Sections.Add(Me.Detalles)
        Me.Sections.Add(Me.PieDePagina)
        Me.StyleSheet.Add(New DDCssLib.StyleSheetRule("font-family: Arial; font-style: normal; text-decoration: none; font-weight: norma" & _
                    "l; color: Black; ddo-char-set: 204; font-size: 8pt; ", "Normal"))
        Me.StyleSheet.Add(New DDCssLib.StyleSheetRule("font-weight: bold; ddo-char-set: 204; font-size: 14pt; ", "Heading1", "Normal"))
        Me.StyleSheet.Add(New DDCssLib.StyleSheetRule("font-family: Times New Roman; font-size: 14pt; font-weight: bold; font-style: ita" & _
                    "lic; ", "Heading2", "Normal"))
        Me.StyleSheet.Add(New DDCssLib.StyleSheetRule("font-size: 13pt; font-weight: bold; ", "Heading3", "Normal"))

        CType(Me.lblTitulo, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me, System.ComponentModel.ISupportInitialize).EndInit()
    End Sub
#End Region
#Region "Funciones de conversion y asignacion"
    ''' <summary>
    '''  Modifica un objeto label y lo coloca como encabezado
    ''' </summary>
    ''' <param name="label">Label objeto a modificar</param>
    ''' <param name="sName">Nombre del objeto</param>
    ''' <param name="sEtiqueta">Texto de la etiqueta</param>
    ''' <param name="sWidth">Tamaño del texto</param>
    ''' <param name="sLeft">Posicion del texto sobre la hoja</param>
    ''' <returns>DataDynamics.ActiveReports.Label</returns>
    ''' <remarks>Previamente deberas instancia el objeto y asi evitar una excepción</remarks>
    Private Function LabelAsigna(ByRef label As DataDynamics.ActiveReports.Label, _
                                ByVal sName As String, ByVal sEtiqueta As String, ByVal sWidth As Single, _
                                ByVal sLeft As Single) As DataDynamics.ActiveReports.Label
        label.Border.BottomColor = System.Drawing.Color.Black
        label.Border.BottomStyle = DataDynamics.ActiveReports.BorderLineStyle.None
        label.Border.LeftColor = System.Drawing.Color.Black
        label.Border.LeftStyle = DataDynamics.ActiveReports.BorderLineStyle.None
        label.Border.RightColor = System.Drawing.Color.Black
        label.Border.RightStyle = DataDynamics.ActiveReports.BorderLineStyle.None
        label.Border.TopColor = System.Drawing.Color.Black
        label.Border.TopStyle = DataDynamics.ActiveReports.BorderLineStyle.None
        label.Height = 0.2!
        label.HyperLink = Nothing
        label.Left = sLeft
        label.Name = sName
        label.Style = "font-weight: bold; "
        label.Text = sEtiqueta
        label.Top = 0.5!
        label.Width = sWidth
        Return label
    End Function
    ''' <summary>
    ''' Modifica el objeto textbox y le asigna las propiedades pertinentes
    ''' </summary>
    ''' <param name="textbox">TextBox por referencia a modificar</param>
    ''' <param name="sName">Nombre en tiempo de ejecucion</param>
    ''' <param name="sfield">Campo al que se debe asociar</param>
    ''' <param name="sWidth">Tamaño del texto</param>
    ''' <param name="sLeft">Posicion del texto sobre la hoja</param>
    ''' <returns>DataDynamics.ActiveReports.TextBox</returns>
    ''' <remarks>Previamente deberas instancia el objeto y evitar una excepcion</remarks>
    Private Function TextBoxAsigna(ByRef textbox As DataDynamics.ActiveReports.TextBox, ByVal sName As String, _
                                   ByVal sfield As String, ByVal sWidth As Single, ByVal sLeft As Single) _
                                    As DataDynamics.ActiveReports.TextBox
        textbox.Border.BottomColor = System.Drawing.Color.Black
        textbox.Border.BottomStyle = DataDynamics.ActiveReports.BorderLineStyle.None
        textbox.Border.LeftColor = System.Drawing.Color.Black
        textbox.Border.LeftStyle = DataDynamics.ActiveReports.BorderLineStyle.None
        textbox.Border.RightColor = System.Drawing.Color.Black
        textbox.Border.RightStyle = DataDynamics.ActiveReports.BorderLineStyle.None
        textbox.Border.TopColor = System.Drawing.Color.Black
        textbox.Border.TopStyle = DataDynamics.ActiveReports.BorderLineStyle.None
        textbox.DataField = sfield
        textbox.Height = 0.2!
        textbox.Left = sLeft
        textbox.Name = sName
        textbox.Style = "text-align: left; "
        textbox.Text = ""
        textbox.Top = 0.0!
        textbox.Width = sWidth
        Return textbox
    End Function
    ''' <summary>
    ''' Rutina de agregado de objetos
    ''' </summary>
    ''' <param name="sName">Nombre generico de los objetos</param>
    ''' <param name="sEtiqueta">Etiqueta del reporte</param>
    ''' <param name="sCampo">Campo a vilcular</param>
    ''' <param name="sWitdh">Tamaño de los objetos</param>
    ''' <remarks></remarks>
    Private Sub Agrega(ByVal sName As String, ByVal sEtiqueta As String, ByVal sCampo As String , ByVal sWitdh As Single)
        Dim LABEL As New DataDynamics.ActiveReports.Label
        Dim TEXTBOX As New DataDynamics.ActiveReports.TextBox
        CType(LABEL, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(TEXTBOX, System.ComponentModel.ISupportInitialize).BeginInit()
        LABEL = LabelAsigna(LABEL, "lbl" & sName, sEtiqueta, sWitdh, xPos)
        TEXTBOX = TextBoxAsigna(TEXTBOX, "txt" & sName, sCampo, sWitdh, xPos)
        Me.Encabezado.Controls.Add(LABEL)       ' Lo agregamos al reporte
        Me.Detalles.Controls.Add(TEXTBOX)       ' Lo agregamos al reporte
        CType(LABEL, System.ComponentModel.ISupportInitialize).EndInit()
        CType(TEXTBOX, System.ComponentModel.ISupportInitialize).EndInit()
        xPos = xPos + LABEL.Width + xDis        ' Cambio de posicion de los objetos
    End Sub
    ''' <summary>
    ''' Rutina de agregado de objetos
    ''' </summary>
    ''' <param name="sName">Nombre generico de los objetos</param>
    ''' <param name="sEtiqueta">Etiqueta del reporte</param>
    ''' <param name="sCampo">Campo a vilcular</param>
    ''' <param name="sWitdh">Tamaño de los objetos</param>
    ''' <param name="sFormat">Formato de salida de acuerdo al Active Reports</param>
    ''' <remarks></remarks>
    Private Sub Agrega(ByVal sName As String, ByVal sEtiqueta As String, ByVal sCampo As String, ByVal sWitdh As Single,ByVal sFormat As String)
        Dim LABEL As New DataDynamics.ActiveReports.Label
        Dim TEXTBOX As New DataDynamics.ActiveReports.TextBox
        CType(LABEL, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(TEXTBOX, System.ComponentModel.ISupportInitialize).BeginInit()
        LABEL = LabelAsigna(LABEL, "lbl" & sName, sEtiqueta, sWitdh, xPos)
        TEXTBOX = TextBoxAsigna(TEXTBOX, "txt" & sName, sCampo, sWitdh, xPos)
        TEXTBOX.OutputFormat = sFormat
        Me.Encabezado.Controls.Add(LABEL)
        Me.Detalles.Controls.Add(TEXTBOX)
        CType(LABEL, System.ComponentModel.ISupportInitialize).EndInit()
        CType(TEXTBOX, System.ComponentModel.ISupportInitialize).EndInit()
        xPos = xPos + LABEL.Width + xDis
    End Sub
#End Region

End Class
